<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>CanonicalUrl - Url Test</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script src="assets/jsunittest.js" type="text/javascript"></script>
    <script src="../src/canonical-url.user.js" type="text/javascript"></script>
    <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
  </head>
  <body>

    <div id="content">

      <div id="header">
        <h1>JavaScript unit test file</h1>
      </div>

      <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
      <div id="testlog"></div>
  
      <!-- Put sample/test html here -->
      <div id="sample">
      </div>
    </div>

    <script type="text/javascript">
    // <![CDATA[
      new Test.Unit.Runner({
        setup: function() {
          this.location = document.createElement('a');
        },
    
        teardown: function() {
        },
        
        'test should delegate to the Location object for all location properties': function() { with(this) {
          location.href = 'http://www.example.com:8080/foo/bar/?q=query#my-hash';
          var url = new CanonicalUrl.Url(location);
          
          assertEqual(location.hash, url.hash);
          assertEqual(location.host, url.host);
          assertEqual(location.hostname, url.hostname);
          assertEqual(location.href, url.href);
          assertEqual(location.pathname, url.pathname);
          assertEqual(location.port, url.port);
          assertEqual(location.protocol, url.protocol);
          assertEqual(location.search, url.search);
        }},
        
        'test should return an object representing the querystring' : function() { with(this) {
          location.href = 'http://localhost/?foo=bar&bar=baz';
          var url = new CanonicalUrl.Url(location);
          var expectedQueryString = { 'foo' : 'bar', 'bar' : 'baz' };
          // I'm not sure whether toSource can be guaranteed to give reliable serialization of objects
          assertEqual(expectedQueryString.toSource(), url.queryString.toSource());
        }}

      }); 
    // ]]>
    </script>
  </body>
</html>